package com.huifan.demo.revenue.servyou;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

import static com.huifan.demo.revenue.servyou.ServyouService.CODE_0000;

/**
 * @author: liuchenhui
 * @create: 2019-08-15 16:25
 **/
@SuppressWarnings("all")
public class TaxationDeclare {
    /**
     * 获取申报数据
     *
     * @param id 人员报送反馈id
     */
    public static Map<String, Object> getGssbData(String id) {
        String request = ServyouService.ryxxfkztcx(id);

        JSONObject jsonObject = JSON.parseObject(request);
        String code = jsonObject.getString("code");
        String msg = jsonObject.getString("msg");
        JSONObject dataJson = jsonObject.getJSONObject("data");
        JSONArray bsjg = dataJson.getJSONArray("bsjg");
        if (!CODE_0000.equals(code)) {
            throw new RuntimeException(msg);
        }

        // 总人数
        BigDecimal zrs = new BigDecimal(bsjg.size());
        BigDecimal zje = new BigDecimal("40000");
        BigDecimal ynse = new BigDecimal("0");


        Map<String, Object> gssbData = new HashMap<>();
        Map<String, Object> ykyj = new HashMap<>();
        ykyj.put("zrs", zrs);
        ykyj.put("zje", zje);
        ykyj.put("ynse", ynse);

        gssbData.put("ykyj", ykyj);
        gssbData.put("flsd", new HashMap<>());
        gssbData.put("fjm", new HashMap<>());
        return gssbData;
    }
}
